package com.netsdk.lht2.util;

import com.netsdk.demo.util.sql.JdbcUtils;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class ZbsetCache {
    static ConcurrentHashMap<String,List<Map<String, Object>>> cache = new ConcurrentHashMap<>();
   public synchronized static List<Map<String, Object>> queryBean(String channel, int nLane) throws SQLException {
       String key = channel+ "-" + nLane;
       List<Map<String, Object>> data = cache.get(key);
       if(data == null){
           String sql3 = "select t.nJun,t.device_address,t.nChannel,t.nLane,t.nLaneNo,t.direction,t.cog,t.size,t.nLaneIndex," +
                   "t.usetime,t.befor,t.total,t.zb1,t.zb2,t.zb3,t.zb4,t.zb5,t.zb6,t.zb7,t.zb8,t.alltime, t.offset  "
                   + ",t.green  from zbset t where nChannel=? and nLaneNo=? and zb1 is not null ";
           data = JdbcUtils.queryBean(sql3, channel, nLane);
           cache.put(key,data);
       }
       return data;
   }
}
